package com.stepcleanse.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.stepcleanse.common.log.annotation.Log;
import com.stepcleanse.common.log.enums.BusinessType;
import com.stepcleanse.common.security.annotation.RequiresPermissions;
import com.stepcleanse.system.domain.LaundryOrder;
import com.stepcleanse.system.service.ILaundryOrderService;
import com.stepcleanse.common.core.web.controller.BaseController;
import com.stepcleanse.common.core.web.domain.AjaxResult;
import com.stepcleanse.common.core.utils.poi.ExcelUtil;
import com.stepcleanse.common.core.web.page.TableDataInfo;

/**
 * 洗涤订单Controller
 * 
 * @author stepcleanse
 * @date 2024-12-09
 */
@RestController
@RequestMapping("/laundryorder")
public class LaundryOrderController extends BaseController
{
    @Autowired
    private ILaundryOrderService laundryOrderService;

    /**
     * 查询洗涤订单列表
     */
    @RequiresPermissions("laundry:order:list")
    @GetMapping("/list")
    public TableDataInfo list(LaundryOrder laundryOrder)
    {
        startPage();
        List<LaundryOrder> list = laundryOrderService.selectLaundryOrderList(laundryOrder);
        return getDataTable(list);
    }

    /**
     * 导出洗涤订单列表
     */
    @RequiresPermissions("laundry:order:export")
    @Log(title = "洗涤订单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LaundryOrder laundryOrder)
    {
        List<LaundryOrder> list = laundryOrderService.selectLaundryOrderList(laundryOrder);
        ExcelUtil<LaundryOrder> util = new ExcelUtil<LaundryOrder>(LaundryOrder.class);
        util.exportExcel(response, list, "洗涤订单数据");
    }

    /**
     * 获取洗涤订单详细信息
     */
    @RequiresPermissions("laundry:order:query")
    @GetMapping(value = "/{factoryOrderId}")
    public AjaxResult getInfo(@PathVariable("factoryOrderId") String factoryOrderId)
    {
        return success(laundryOrderService.selectLaundryOrderByFactoryOrderId(factoryOrderId));
    }

    /**
     * 新增洗涤订单
     */
    @RequiresPermissions("laundry:order:add")
    @Log(title = "洗涤订单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LaundryOrder laundryOrder)
    {
        return toAjax(laundryOrderService.insertLaundryOrder(laundryOrder));
    }

    /**
     * 修改洗涤订单
     */
    @RequiresPermissions("laundry:order:edit")
    @Log(title = "洗涤订单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LaundryOrder laundryOrder)
    {
        return toAjax(laundryOrderService.updateLaundryOrder(laundryOrder));
    }

    /**
     * 删除洗涤订单
     */
    @RequiresPermissions("laundry:order:remove")
    @Log(title = "洗涤订单", businessType = BusinessType.DELETE)
	@DeleteMapping("/{factoryOrderIds}")
    public AjaxResult remove(@PathVariable String[] factoryOrderIds)
    {
        return toAjax(laundryOrderService.deleteLaundryOrderByFactoryOrderIds(factoryOrderIds));
    }
}
